from django.conf import settings
from django.conf.urls.defaults import *
from django.contrib import admin
from django.contrib.comments.feeds import *
from django.contrib.auth.models import *
from clapton.utils.feeds import *
from clapton.utils.sitemap import *

admin.autodiscover()

rssfeeds = {
    'blogs': BlogEntryFeed,
    'documents': DocumentFeed,
    'events': EventFeed,
    'photos': PhotoFeed,
    'podcasts': PodcastFeed,
    'polls': PollFeed,
    'stories': StoryFeed,
}

atomfeeds = {
    'blogs': BlogEntryFeedAtom,
    'documents': DocumentFeedAtom,
    'events': EventFeedAtom,
    'photos': PhotoFeedAtom,
    'podcasts': PodcastFeedAtom,
    'polls': PollFeedAtom,
    'stories': StoryFeedAtom,
}

sitemaps = {
    'blogs': BlogSitemap,
    'documents': DocumentSitemap,
    'events': EventSitemap,
    'photos': PhotoSitemap,
    'podcasts': PodcastSitemap,
    'polls': PollSitemap,
    'stories': StorySitemap,
    'videos': VideoSitemap,
}

urlpatterns = patterns('',
	# Applications
    (r'^blogs/', include('clapton.apps.blogs.urls')),
    (r'^documents/', include('clapton.apps.documents.urls')),
    (r'^events/', include('clapton.apps.events.urls')),
    (r'^photos/', include('clapton.apps.photos.urls')),
    (r'^podcasts/', include('clapton.apps.podcasts.urls')),
    (r'^polls/', include('clapton.apps.polls.urls')),
    (r'^stories/', include('clapton.apps.stories.urls')),
    (r'^videos/', include('clapton.apps.videos.urls')),
    
    # Comments
    (r'^comments/postfree/', 'clapton.utils.views.my_post_free_comment'),
    (r'^comments/', include('django.contrib.comments.urls.comments')),

    # Syndication
    (r'^rss/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': rssfeeds}),
    (r'^atom/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': atomfeeds}),
    
    # Sitemaps
    (r'^sitemap.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}),

    # Search
    (r'^search/', 'django.views.generic.simple.direct_to_template',
        {'template':'search.html'}),
    (r'^search/(?P<terms>.*)/$', 'django.views.generic.simple.direct_to_template',
        {'template':'search.html'}),
    
    # Accounts and Admin
    (r'^accounts/login/$', 'django.contrib.auth.views.login'),
    (r'^accounts/logout', 'django.contrib.auth.views.logout' ),
    (r'^accounts/profile/$', 'django.views.generic.simple.direct_to_template',
        {'template':'profile.html'}),
    (r'^settings/$', 'django.views.generic.simple.direct_to_template',
        {'template': 'settings.html'}),
    (r'^admin/(.*)', admin.site.root),
    
    # For Dev only
    (r'^media/(?P<path>.*)$', 'django.views.static.serve',
        {'document_root': settings.MEDIA_ROOT}),
)
